﻿@{
    ViewBag.Title = "修改密码";
}

<h3>修改密码</h3>
<div align="center">
<hr />
<table class="tb" style="width:500px;">
    <tbody>
        <tr>
            <td><span>原来密码：</span></td>
            <td><input type="password" id="oldPwd"></td>
        </tr>
        <tr>
            <td><span id="Label2">密码：</span></td>
            <td><input type="password" id="newPwd"></td>
        </tr>
        <tr>
            <td><span>确认密码：</span></td>
            <td><input type="password" id="conNewPwd"></td>
        </tr>
    </tbody>
</table>
<hr />
<table class="tb" style="width:500px;text-align:center">
    <tbody>
        <tr>
            <td>
                <input type="button" value="确认" id="btnUpdate" style="width:60px;">
            </td>
        </tr>
    </tbody>
</table> 
<hr />  
</div>
<script type="text/javascript">
    $(function () {
        $("#btnUpdate").bind("click", function () {
            changePwd();
        });

        $('#conNewPwd').bind('keyup', function (event) {
            if (event.keyCode == 13) {
                changePwd();
            }
        });
    });
    
    function changePwd()
    {
        var oldPwd = $("#oldPwd").val();
        var newPwd = $("#newPwd").val();
        var conNewPwd = $("#conNewPwd").val();

        if (oldPwd == "") {
            dlg.Msg.Inf("原始密码不能为空");
            $("#oldPwd").focus();
            return;
        }
        if (newPwd == "") {
            dlg.Msg.Inf("新密码不能为空");
            $("#newPwd").focus();
            return;
        }
        if (conNewPwd == "") {
            dlg.Msg.Inf("请再次输入新密码");
            $("#conNewPwd").focus();
            return;
        }

        if (newPwd != conNewPwd) {
            dlg.Msg.Inf("两次输入不一致");
            $("#conNewPwd").focus();
            return;
        }

        $.ajax({
            type: "post",
            url: "/manage/home/jsonchangepwd",
            data: { oldpwd: oldPwd, newpwd: newPwd },
            dataType: "json",
            timeout: 30000, //over time：30s
            beforeSend: function () {
                window.top.qibu.msgbox.loading("正在提交申请，请稍后... ...");
            },
            success: function (data) {
                window.top.qibu.msgbox.hide();
                if (data.code != 1) {
                    dlg.Msg.Cor("修改成功");
                    setTimeout("location.href='/manage/home'", 1500);
                }
                else {
                    dlg.Msg.Err(data.msg);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                window.top.qibu.msgbox.hide();
                dlg.Msg.Err(errorThrown);
            }
        });
    }
</script>